import steer
import vector


class Flee (steer.Steer):
    
    def __init__(self):
        steer.Steer.__init__(self)
    
    def calculate(self, targetPosition):
        vectorToTarget = self.position.subtract(targetPosition)
        if (vectorToTarget.length() != 0):
            desiredVelocity = (vectorToTarget).normalize().multiple(self.max_speed)
            return desiredVelocity.subtract(self.velocity).cutTo(self.max_speed).multiple(self.mass).cutTo(self.max_force)
        else:
            return vector.Vector(0.0,0.0)
    



    
    